function getcurtime(){
	var now = new Date();
	var year = now.getFullYear();       //年
	var month = now.getMonth() + 1;     //月
	var day = now.getDate();            //日
	if(month < 10)
        month = "0" + month;
    if(day < 10)
		day = "0" + day;
	var tempvalue = year+"-"+month+"-"+day;
	return tempvalue;
}
var curtime = getcurtime();

 
$(document).ready(function(){            
	$("#leaveinfo").jqGrid({                
		url:global_url+global_urijs+'schoollea_searchLeaList_normal'+global_suffix+"?sid="+global_sid+"&tid="+global_tid,                
		datatype:"json",                
		mtype:'GET', 
		height:'300',
		width:'770',                 
		colNames:['姓名','账号','职务','开始时间','结束时间','请假时长(小时)','类型','事由','状态','审批人','操作','教师id','请假编号'],                
		colModel:[                    
		{name:'teacherName',index:'teacherName',width:100,align:'center'},                    
		{name:'tAccount',index:'tAccount',width:100,align:'center'},                    
		{name:'typeName',index:'typeName',width:100,align:'center',sortable:false},
		{name:'sdate_str',index:'sdate_str',width:150,align:'center'},
		{name:'edate_str',index:'edate_str',width:150,align:'center'},
		{name:'leaveTime',index:'leaveTime',width:80,align:'center',sortable:false},
		{name:'type_handle_str',index:'type_handle_str',width:100,align:'center',sortable:false},
		{name:'desinfo',index:'desinfo',width:150,align:'center',sortable:false},
		{name:'state_str',index:'state_str',width:100,align:'center',sortable:false},
		{name:'euid_name',index:'euid_name',width:100,align:'center',sortable:false},
		{name:'revoked',index:'revoked',width:160,sortable:false,align:'center'},
		{name:'tid',index:'tid',hidden:true},
		{name:'lid',index:'lid',hidden:true},
		],
		autowidth:true,
		jsonReader: {
			root:"terLeaves",
			page: "page",
			total: "page_count",
			records : "count",
			repeatitems: false
		},
		pager: jQuery("#leavepage"),
		prmNames : {page:"page",sort: "sort"},
		rowNum: 10,
		//rowList: [10, 20, 30],
		sortname: 'sdate_str',
		hidegrid: false,
		sortorder: 'dasc',
		viewrecords: true,
		caption: '请假信息',
		gridComplete:function(){
			var ids=jQuery("#leaveinfo").jqGrid('getDataIDs');
			for(var i=0; i<ids.length; i++){
				var id=ids[i];   
				var state_str = jQuery("#leaveinfo").jqGrid('getRowData', id).state_str;
				cx = "<a href='javascript:;' class='jqtrow' onclick='delTel(" + id + ")'>撤销</a>";  
				var re="";				
				if(state_str=="通过"){
					re = "";
				}else{
					re = cx;
				}
				jQuery("#leaveinfo").jqGrid('setRowData', ids[i], {revoked:re});
			}
		}
	}).navGrid("#leavepage", { edit: false, add: false, del: false, search: false });
});

function delTel(id){
	 $("#deltname").html(jQuery("#leaveinfo").jqGrid('getRowData', id).sdate_str+"-"+jQuery("#leaveinfo").jqGrid('getRowData', id).edate_str);
	 $(function() {
			$( "#leave_del" ).dialog({
				modal: true,
				resizable: false,
				buttons: {
					"移出": function() {
						var funadd = function(data1){
							if(1==data1.s){
								$().message("移出成功!");
								 $("#leaveinfo").trigger("reloadGrid");
								 $("#leave_del").dialog( "close" );
							}else{
								$().message("移出失败!");
							}
						};
						exeAjax(ajaxUrl("${aier_url}${aier_urijs}leavemanage_delete${aier_suffix}"), funadd, {"lid" :jQuery("#leaveinfo").jqGrid('getRowData', id).lid});
					},"取消": function() {
						$( this ).dialog( "close" );
					}
				}
			});
		});
}
